import Toast from '../../../miniprogram_npm/tdesign-miniprogram/toast/index';
import Dialog from '../../../miniprogram_npm/tdesign-miniprogram/dialog/index';

interface IPageData {
  dialogVisible: boolean;
}

interface IPageInstance {
  data: IPageData;
  showToast(type: string): void;
  showDialog(): void;
  onConfirm(): void;
  onCancel(): void;
}

Page<IPageData, IPageInstance>({
  data: {
    dialogVisible: false
  },

  showToast(type: string) {
    Toast({
      context: this,
      selector: '#t-toast',
      message: `这是一条${type}提示`,
      theme: type as any,
      duration: 2000
    });
  },

  showDialog() {
    this.setData({ dialogVisible: true });
  },

  onConfirm() {
    this.setData({ dialogVisible: false });
    this.showToast('success');
  },

  onCancel() {
    this.setData({ dialogVisible: false });
  }
}); 